package pers.litao.bit.product.controller;

import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import pers.litao.bit.commons.utils.R;
import pers.litao.bit.product.service.LabelService;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * @author 李涛
 * @date 2020-11-26 15:37
 */
@RestController
@RequestMapping("/product/label")
public class LabelController {
    @Resource
    private LabelService labelService;

//    @RequestMapping("/init")
//    public R init(){
//        labelService.init();
//        return R.ok();
//    }

    /**
     * 获取分类列表
     *
     * @return
     */
    @RequestMapping(value = "/list")
    public R getList(){
        return labelService.getList();
    }

    /**
     * 根据ID集合查标签，内部调用
     *
     * @return
     */
    @RequestMapping(value = "/listByIds",method = RequestMethod.POST)
    public R getListLabelByIds(@RequestBody List<Long> ids){
       if(ids == null || ids.size() == 0){
           return R.ok(new ArrayList<>());
       }
        return R.ok(labelService.listByIds(ids));
    }
}
